package com.ruoyi.student.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.student.domain.TStudentDetail;
import com.ruoyi.student.service.ITStudentDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 学生详情Controller
 * 
 * @author ruoyi
 * @date 2022-12-24
 */
@RestController
@RequestMapping("/studentDetail")
public class TStudentDetailController extends BaseController
{
    @Autowired
    private ITStudentDetailService tStudentDetailService;

    /**
     * 查询学生详情列表
     */
    @RequiresPermissions("student:studentDetail:list")
    @GetMapping("/list")
    public TableDataInfo list(TStudentDetail tStudentDetail)
    {
        startPage();
        List<TStudentDetail> list = tStudentDetailService.selectTStudentDetailList(tStudentDetail);
        return getDataTable(list);
    }

    /**
     * 导出学生详情列表
     */
    @RequiresPermissions("student:studentDetail:export")
    @Log(title = "学生详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TStudentDetail tStudentDetail)
    {
        List<TStudentDetail> list = tStudentDetailService.selectTStudentDetailList(tStudentDetail);
        ExcelUtil<TStudentDetail> util = new ExcelUtil<TStudentDetail>(TStudentDetail.class);
        util.exportExcel(response, list, "学生详情数据");
    }

    /**
     * 获取学生详情详细信息
     */
    @RequiresPermissions("student:studentDetail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tStudentDetailService.selectTStudentDetailById(id));
    }

    /**
     * 新增学生详情
     */
    @RequiresPermissions("student:studentDetail:add")
    @Log(title = "学生详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TStudentDetail tStudentDetail)
    {
        return toAjax(tStudentDetailService.insertTStudentDetail(tStudentDetail));
    }

    /**
     * 修改学生详情
     */
    @RequiresPermissions("student:studentDetail:edit")
    @Log(title = "学生详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TStudentDetail tStudentDetail)
    {
        return toAjax(tStudentDetailService.updateTStudentDetail(tStudentDetail));
    }

    /**
     * 删除学生详情
     */
    @RequiresPermissions("student:studentDetail:remove")
    @Log(title = "学生详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tStudentDetailService.deleteTStudentDetailByIds(ids));
    }


}
